package com.caigou.modules.login.repository

import com.caigou.comm.base.bean.HttpResult
import com.caigou.comm.base.bean.UserBean
import com.caigou.modules.login.network.HttpMainService
import dagger.hilt.android.scopes.ActivityRetainedScoped
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
import javax.inject.Inject

/**
 * @author #Suyghur.
 * Created on 2021/09/27
 */
@ActivityRetainedScoped
class MainRepository @Inject constructor() {

    fun autoLauncher(mobile: String, password: String): Flow<HttpResult<UserBean>> {
        val jsonObjects = JSONObject()
        jsonObjects.put("mobile", mobile)
        jsonObjects.put("password", password)
        val body = jsonObjects.toString().toRequestBody()
        return HttpMainService.service.autoLauncher(body)
    }

}